package com.o2o.cleaning.month.platform.ebusiness_plat.jumei_2019_7.Jumei_utils

import java.net.URI

import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.{FileStatus, FileSystem, FileUtil, Path}

/**
  * @Description TODO 
  * @Author liutaowei
  * @Date 2019/3/25 10:44
  */
object path_util {
//  def main(args: Array[String]): Unit = {
//    val res = newnest_path("s3a://o2o-dimension-table/category_table/categoryFile_tao/jumei/")
//    println(res)
//  }


  def newnest_path(obs_path:String):String ={
    val conf1 = new Configuration()
    conf1.set("fs.s3a.access.key", "GAO7EO9FWKPJ8WFCQDME")
    conf1.set("fs.s3a.secret.key", "LZ0xaHBSYKHaJ9ECDbX9f7zin79UZkXfGoNapRPL")
    conf1.set("fs.s3a.endpoint", "https://obs.cn-north-1.myhuaweicloud.com")

    val fileSystem = FileSystem.get(URI.create(obs_path),conf1)
    val statuses: Array[FileStatus] = fileSystem.listStatus(new Path(obs_path))
    val paths = FileUtil.stat2Paths(statuses)

    val bt = paths.map{line=>line.getParent +"/"+line.getName}.sortBy(x=>x.reverse)
    bt.foreach(println(_))
    val tr = bt.take(1).mkString

    tr
  }
}
